package com.jxc.service.impl;

import com.jxc.mapper.UserRoleMapper;
import com.jxc.pojo.UserRole;
import com.jxc.pojo.UserRoleExample;
import com.jxc.service.UserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserRoleServiceImpl implements UserRoleService {
    @Resource
    private UserRoleMapper userRoleMapper;
    @Override
    public int deleteByExample(Integer urid) {
        UserRoleExample ure = new UserRoleExample();
        ure.createCriteria().andUserIdEqualTo(urid);
        System.out.println(ure);
        return userRoleMapper.deleteByExample(ure);
    }

    /**删除用户中间表
     * @param userId
     * @return
     */
    @Override
    public int delUserRoles(Integer userId) {
        System.out.println("删除用户中间表==="+userId);
        return userRoleMapper.delUserRoles(userId);
    }

    /**
     * 删除角色中间表
     * @param roleId
     * @return
     */
    @Override
    public int delUserRolesById(Integer roleId) {
        System.out.println("删除角色中间表==="+roleId);
        return userRoleMapper.delUserRolesById(roleId);
    }

    @Override
    public int insertSelective(UserRole record) {
        return userRoleMapper.insertSelective(record);
    }
}
